package com.wavehi.common;

import lombok.Getter;
import lombok.Setter;

/**
 * @Description
 * @Author WaveHi
 * @Date 2/12/2021 下午 1:30
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 */
@Getter
public enum MyEnum {
    LOGIN(100, "已登录"), LOGOUT(200, "下线"), CANCEL(500, "注销");
    private Integer code;
    private String msg;
    private MyEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    /**
     * 根据状态码获取指定的枚举对象
     * @param code 状态码
     * @return 放回状态码对应的枚举队形
     */
    public static MyEnum forMyEnum(Integer code) {
        switch (code) {
            case 100 :
                return LOGIN;
            case 200 :
                return LOGOUT;
            case 500 :
                return CANCEL;
            default:
                return CANCEL;
        }
    }
}
